package cjgl.dao;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectionFactory {
	private static String driverName="com.mysql.jdbc.Driver";
	private static String protocol="jdbc:mysql://";
	private static String address ="localhost";
	private static String port="3306";
	private static String dbName="test";
	private static String username="root";
	private static String password="root";
	public static Connection getConnection(){
		Connection conn= null;
		try {
			Class.forName(driverName);
			conn= DriverManager.getConnection(protocol+address+":"+port+"/"+dbName, username, password);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
	
	public static String getDriverName() {
		return driverName;
	}
	public static void setDriverName(String driverName) {
		ConnectionFactory.driverName = driverName;
	}
	public static String getProtocol() {
		return protocol;
	}
	public static void setProtocol(String protocol) {
		ConnectionFactory.protocol = protocol;
	}
	public static String getAddress() {
		return address;
	}
	public static void setAddress(String address) {
		ConnectionFactory.address = address;
	}
	public static String getPort() {
		return port;
	}
	public static void setPort(String port) {
		ConnectionFactory.port = port;
	}
	public static String getDbName() {
		return dbName;
	}
	public static void setDbName(String dbName) {
		ConnectionFactory.dbName = dbName;
	}
	public static String getUsername() {
		return username;
	}
	public static void setUsername(String username) {
		ConnectionFactory.username = username;
	}
	public static String getPassword() {
		return password;
	}
	public static void setPassword(String password) {
		ConnectionFactory.password = password;
	}
	
	
}
